<template>
<div class="app">
  <h2>当前计数：{{counter}}</h2>
  <AddCounter v-on="{add:addBtnClick}"></AddCounter>
  <SubCounter v-on="{sub:addBtnClick}"></SubCounter>
</div>
</template>

<script>
import AddCounter from './AddCounter.vue';
import SubCounter from './SubCounter.vue';
export default {
  name: "App",
  components:{
    AddCounter,
    SubCounter
  },
  data(){
    return{
      counter:0
    }
  },
  methods:{
    addBtnClick(payload){
      console.log("payload:",payload)
      this.counter+=payload
    }
  }
}
</script>

<style scoped>

</style>